package com.noahplat.person.controller;

import com.noahplat.common.utils.Result;
import com.noahplat.person.pojo.PersonBase;
import com.noahplat.person.service.PersonBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * @ClassName: PersonBaseController
 * @Description: 人员基本信息对外接口
 * @Author 李景星
 * @Date 2021/3/6
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/personBase")
@Validated
public class PersonBaseController {

    @Autowired
    private PersonBaseService personBaseService;

    /**
     * 查询用户基本信息
     * @param pid
     * @return
     */
    @PreAuthorize("hasAuthority('noahplat-service-person:PersonBaseController:getPersonBase')")
    @GetMapping("/getPersonBase")
    public Result getPersonBase(@NotNull(message = "人员ID不能为空 ") @Min(value = 1, message = "人员ID不合法") Long pid){
        return personBaseService.getPersonBase(pid);
    }

    /**
     * 更新人员基本信息
     * @param personBase
     * @return
     */
    @PreAuthorize("hasAuthority('noahplat-service-person:PersonBaseController:updatePersonBase')")
    @PutMapping("/updatePersonBase")
    public Result updatePersonBase(@RequestBody PersonBase personBase){
        return personBaseService.updatePersonBase(personBase);
    }


}
